#include "bulkoperationwidget.h"

BulkOperationWidget::BulkOperationWidget(QWidget *parent)
    : QWidget{parent}
{
    hlayout=new QHBoxLayout(this);
    addplaylistbtn=new QPushButton("添加到播放列表",this);
    downloadbtn=new QPushButton("下载",this);
    favorbtn=new QPushButton("收藏",this);
    deletebtn=new QPushButton("删除",this);
    okbtn=new QPushButton("完成",this);

    hlayout->addWidget(addplaylistbtn);
    hlayout->addWidget(downloadbtn);
    hlayout->addWidget(favorbtn);
    hlayout->addWidget(deletebtn);
    hlayout->addStretch(1);
    hlayout->addWidget(okbtn);
    hlayout->setSpacing(10);

    addplaylistbtn->setIcon(QIcon(":/icon/add.png"));
    downloadbtn->setIcon(QIcon(":/icon/download.png"));
    favorbtn->setIcon(QIcon(":/icon/favor.png"));
    deletebtn->setIcon(QIcon(":/icon/delete.png"));

    connect(addplaylistbtn,&QPushButton::clicked,[this]{emit addPlayList();});
    connect(downloadbtn,&QPushButton::clicked,[this]{emit download();});
    connect(favorbtn,&QPushButton::clicked,[this]{emit favor();});
    connect(deletebtn,&QPushButton::clicked,[this]{emit delete_();});
    connect(okbtn,&QPushButton::clicked,[this]{emit OK();});

    SetStyleSheet(addplaylistbtn);
    SetStyleSheet(downloadbtn);
    SetStyleSheet(favorbtn);
    SetStyleSheet(deletebtn);
    SetStyleSheet(okbtn);
}

void BulkOperationWidget::SetStyleSheet(QPushButton*btn)
{
    btn->setStyleSheet("QPushButton{"
                       "background:#f0f3f6;"
                       "border-radius:10px;"
                       ""
                       "}");
    btn->setFont(QFont("Microsoft YaHei",12));
    QFontMetrics metrics(btn->font());
    btn->setFixedWidth(metrics.boundingRect(btn->text()).width()+50);
    btn->setFixedHeight(40);
}
